import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;

import javax.swing.JSplitPane;
import javax.swing.JEditorPane;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;

import javax.swing.border.EmptyBorder;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;

public class WeatherArchiverPanel extends JPanel {
    static Document document;
    static final int windowHeight = 460;
    static final int leftWidth = 300;
    static final int rightWidth = 340;
    static final int windowWidth = leftWidth + rightWidth;
    
    public WeatherArchiverPanel(Document doc) {
	EmptyBorder eb = new EmptyBorder(5, 5, 5, 5);
	BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
	CompoundBorder cb = new CompoundBorder(eb, bb);
	this.setBorder(new CompoundBoder(cb, eb));
	
	// set up the tree
	JTree tree = new JTree();

	// build left-side view
	JScrollPane treeView = new JScrollPane(tree);
	treeView.setPreferredSize(new Dimension(leftWidth, windowHeight));

	// build right-side view
	JEditorPane htmlPane = new JEditorPane("text/html", "");
	htmlPane.setEditable(false);
	JScrollPane htmlView = new JScrollPane(htmlPane);
	htmlView.setPreferredSize(new Dimension(rightWidth, windowHeight));
	
	// build split-pane view
	JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
					      treeView, htmlView);
	splitPane.setContinuousLayout(true);
	splitPane.setDividerLocation(leftWidth);
	splitPane.setPreferredSize(new Dimension(windowWidth + 10, 
						 windowHeight + 10));
	
	this.setLayout(new BorderLayout());
	this.add("Center", splitPane);
    }
}
